package com.example.jh352160.surfingtv.Index.customView;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;

import com.example.jh352160.surfingtv.Index.customView.adapter.CommodityRecyclerViewAdapter;
import com.example.jh352160.surfingtv.R;

import java.util.List;

/**
 * Created by jh352160 on 2016/7/20
 */

public class ItemIndexColumn extends LinearLayout {

    IndexColumnBigImage indexColumnBigImage;
    RecyclerView recyclerView;
    Context context;
    CommodityRecyclerViewAdapter adapter;
    List<String> names, lineTags, prices, imageUrls, fromList, detilUrlList;
    List<Integer> targetIdList;
    List<Boolean> isLikeList;

    public ItemIndexColumn(Context context, List<String> imageUrls, List<String> names, List<String> linetags, List<String> prices, List<String> fromList, List<String> detilUrlList, List<Boolean> isLikeList, List<Integer> targetId) {
        super(context);
        this.context = context;
        this.names = names;
        this.imageUrls = imageUrls;
        this.lineTags = linetags;
        this.prices = prices;
        this.fromList = fromList;
        this.detilUrlList = detilUrlList;
        this.isLikeList = isLikeList;
        this.targetIdList = targetId;
        init();
    }

    public ItemIndexColumn(Context context) {
        super(context);
        this.context = context;
        init();
    }

    public ItemIndexColumn(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.context = context;
        init();
    }

    private void init() {
        LayoutInflater.from(context).inflate(R.layout.item_index_column, this);
//        List<String> names=new ArrayList<>();
//        List<String> lineTags=new ArrayList<>();
//        List<String> prices =new ArrayList<>();
//        List<String> imageUrls =new ArrayList<>();

        adapter = new CommodityRecyclerViewAdapter(context, imageUrls, names, lineTags, prices, fromList, detilUrlList, isLikeList, targetIdList);
        indexColumnBigImage = (IndexColumnBigImage) findViewById(R.id.column_big_image);
        recyclerView = (RecyclerView) findViewById(R.id.commodityList);

    }

    public void setImage(int titleImage, String bigImage, int adType, int contentId) {
        indexColumnBigImage.setImage(titleImage, bigImage, adType, contentId);
    }

    public void setAdapter() {
        LinearLayoutManager llm = new LinearLayoutManager(context);
        llm.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(llm);
        recyclerView.setAdapter(adapter);
    }

//    public void setDetailData(List<String> from,List<String> DetilUrl,List<Boolean> isLike){
//
//    }
}
